[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 textwidth()             Get a String's Width in Pixels

 #include   <graphics.h>

 int far    textwidth(tstring);
 char far   *tstring;

    textwidth() gets the width of 'tstring' in pixels by using the length
    of 'tstring', the current text font size and multiplication factor.
    textheight() and textwidth() are used for sizing strings that need to
    be fit into existing spaces.

    Returns:     The text width in pixels.

   -------------------------------- Example ---------------------------------

    The following statements size the word "squeeze" and print it in a
    small box.

           #include <graphics.h>
           #include <conio.h>

           main()
           {
               int gdriver = DETECT;
               int gmode;
               char *txt = "Squeeze";

               initgraph(&gdriver,&gmode,"");
               settextjustify(CENTER_TEXT,CENTER_TEXT);
               settextstyle(SANS_SERIF_FONT,HORIZ_DIR,USER_CHAR_SIZE);
               setusercharsize(60,textwidth(txt),50,textheight(txt));
               settextstyle(SANS_SERIF_FONT,HORIZ_DIR,USER_CHAR_SIZE);
               rectangle(290,125,350,175);
               outtextxy(320,150,txt);
               getch();
               closegraph();
           }


See Also: gettextsettings() outtext() textheight()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson